package com.neusoft.elmboot.service.Impl;

import com.neusoft.elmboot.mapper.BusinessMapper;
import com.neusoft.elmboot.po.Business;
import com.neusoft.elmboot.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Service
public class BusinessServiceImpl implements BusinessService {

    private static final Logger logger = LoggerFactory.getLogger(BusinessServiceImpl.class);

    @Autowired
    private BusinessMapper businessMapper;

    @Override
    public List<Business> listBusinessByOrderTypeId(Integer orderTypeId) {
        try {
            return businessMapper.listBusinessByOrderTypeId(orderTypeId);
        } catch (Exception e) {
            logger.error("Error occurred while fetching businesses by orderTypeId: {}", orderTypeId, e);
            throw new RuntimeException("Failed to fetch businesses. Please try again later.", e);
        }
    }

    @Override
    public Business getBusinessById(Integer businessId) {
        try {
            return businessMapper.getBusinessById(businessId);
        } catch (Exception e) {
            logger.error("Error occurred while fetching business by id: {}", businessId, e);
            throw new RuntimeException("Failed to fetch business details. Please try again later.", e);
        }
    }
}








//    package com.neusoft.elmboot.service.Impl;
//
//import com.neusoft.elmboot.mapper.BusinessMapper;
//import com.neusoft.elmboot.po.Business;
//import com.neusoft.elmboot.service.BusinessService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.util.List;
//    @Service
//    public class BusinessServiceImpl implements BusinessService {
//
//        @Autowired
//        private BusinessMapper businessMapper;
//        @Override
//        public List<Business> listBusinessByOrderTypeId(Integer orderTypeId){
//            return businessMapper.listBusinessByOrderTypeId(orderTypeId);
//        }
//
//        @Override
//        public Business getBusinessById(Integer businessId) {
//            return businessMapper.getBusinessById(businessId);
//        }
//    }
//}